﻿#include<iostream>
#include<list>


void printList(const std::list<int>& L)
{
	for (std::list<int>::const_iterator it = L.begin(); it != L.end(); ++it)
	{
		std::cout << *it << " ";
	}
	std::cout << '\n';
}

void test01()
{
	std::list<int>L1;
	//尾插 
	L1.push_back(0);
	L1.push_back(1);
	L1.push_back(2);
	L1.push_back(3);
	//头插
	L1.push_front(1);
	L1.push_front(2);
	L1.push_front(3);
	//3 2 1 0 1 2 3
	printList(L1);

	//头删
	//2 1 0 1 2 3
	L1.pop_front();
	printList(L1);

	//尾删
	//2 1 0 1 2
	L1.pop_back();
	printList(L1);

	//插入
	//2 6 1 0 1 2
	std::list<int>::iterator it = L1.begin();
	L1.insert(++it, 6);
	printList(L1);

	//删除
	//2 1 0 1 2
	it = L1.begin();
	L1.erase(++it);
	printList(L1);

	//2 2
	L1.erase(++L1.begin() , --L1.end());
	printList(L1);

	L1.push_back(666);
	L1.push_back(666);
	L1.push_back(666);
	printList(L1);

	L1.remove(666);
	printList(L1);

	L1.clear();
	printList(L1);
}

int main()
{
	test01();




	return 0;
}